package TestCase;

import com.beanit.iec61850bean.ClientAssociation;
import com.beanit.iec61850bean.ClientEventListener;
import com.beanit.iec61850bean.ClientSap;
import com.beanit.iec61850bean.Report;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;

public class Test_Case_0 implements ClientEventListener {
    private static final Logger logger = LoggerFactory.getLogger(Test_Case_0.class);


    private ClientAssociation clientAssociation;
    public void Test_Case_0(String host){
        InetAddress address ;
        try {
            address = InetAddress.getByName(host);
        } catch (UnknownHostException e) {
            System.out.println("Unknown host: " + host);
            return;
        }

        ClientSap clientSap = new ClientSap();
        logger.info("Creat and init Client Sap");
        try {
            clientAssociation = clientSap.associate(address, 102, null, this);
        } catch (IOException e) {
            System.out.println("Unable to connect to remote host.");
            return;
        }

        System.out.println("successfully connected");
        //------------BRCB Report Test------------
        //clientAssociation.enableReporting();
        //clientAssociation.setRcbValues();

        clientAssociation.disconnect();
        clientAssociation.close();

    }

    @Override
    public void newReport(Report report) {

    }

    @Override
    public void associationClosed(IOException e) {

    }
}
